package o;

import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.io.BufferedReader;
import java.io.IOException;

public class doa {
    private byte[] ˋ;
    private int ˎ;
    private int ॱ;

    public doa() {
        this.ˋ = null;
        this.ˎ = 8192;
        this.ॱ = 0;
        this.ˋ = new byte[this.ˎ];
    }

    public static String ˋ(byte[] bArr) {
        int i = 0;
        char[] cArr = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
        char[] cArr2 = new char[(bArr.length * 2)];
        int length = bArr.length;
        int i2 = 0;
        while (i < length) {
            byte b = bArr[i];
            int i3 = i2 + 1;
            cArr2[i2] = cArr[(b >>> 4) & 15];
            i2 = i3 + 1;
            cArr2[i3] = cArr[b & 15];
            i++;
        }
        return cArr2;
    }

    public static byte[] ˎ(char[] cArr) throws IllegalArgumentException {
        int i = 0;
        int length = cArr.length;
        if ((length & 1) != 0) {
            throw new IllegalArgumentException("Odd number of characters.");
        }
        byte[] bArr = new byte[(length >> 1)];
        int i2 = 0;
        while (i < length) {
            i++;
            i++;
            bArr[i2] = (byte) (((ˊ(cArr[i], i) << 4) | ˊ(cArr[i], i)) & 255);
            i2++;
        }
        return bArr;
    }

    protected static int ˊ(char c, int i) throws IllegalArgumentException {
        int digit = Character.digit(c, 16);
        if (digit != -1) {
            return digit;
        }
        throw new IllegalArgumentException("Illegal hexadecimal character " + c + " at index " + i);
    }

    public static String ˊ(BufferedReader bufferedReader, int i) throws IOException {
        StringBuilder stringBuilder = new StringBuilder(WXMediaMessage.DESCRIPTION_LENGTH_LIMIT);
        while (true) {
            int read = bufferedReader.read();
            if (read == -1) {
                return stringBuilder.toString();
            }
            if (!(read == 13 || read == 10)) {
                stringBuilder.append((char) read);
                if (stringBuilder.length() >= i) {
                    Logger.e("ByteUtil", "readStringByOneChar -> the read chars counts is reached the maxAllowChars = " + i + "sb.length = " + stringBuilder.length());
                    return stringBuilder.toString();
                }
            }
        }
    }

    public static String ॱ(BufferedReader bufferedReader, int i) throws IOException {
        if (bufferedReader == null) {
            return null;
        }
        StringBuilder stringBuilder = new StringBuilder(WXMediaMessage.DESCRIPTION_LENGTH_LIMIT);
        int i2 = 0;
        do {
            int read = bufferedReader.read();
            if (read != -1) {
                i2++;
                if (read == 13) {
                    bufferedReader.mark(1);
                    if (bufferedReader.read() != 10) {
                        bufferedReader.reset();
                    }
                } else if (read != 10) {
                    stringBuilder.append((char) read);
                }
            }
            if (i2 == 0) {
                return null;
            }
            return stringBuilder.toString();
        } while (stringBuilder.length() < i);
        Logger.e("ByteUtil", "readLineByOneChar -> the read chars counts is reached the maxAllowChars = " + i + "sb.length = " + stringBuilder.length());
        return stringBuilder.toString();
    }

    public static String ˎ(byte[] bArr) {
        StringBuilder stringBuilder = new StringBuilder();
        for (byte b : bArr) {
            String toHexString = Integer.toHexString(b & 255);
            if (toHexString.length() == 1) {
                stringBuilder.append('0');
            }
            stringBuilder.append(toHexString);
        }
        return stringBuilder.toString();
    }

    public static byte[] ˊ(String str) {
        char[] toCharArray = str.toCharArray();
        int length = toCharArray.length / 2;
        byte[] bArr = new byte[length];
        for (int i = 0; i < length; i++) {
            int digit = (Character.digit(toCharArray[i * 2], 16) << 4) | Character.digit(toCharArray[(i * 2) + 1], 16);
            if (digit > 127) {
                digit -= 256;
            }
            bArr[i] = (byte) digit;
        }
        return bArr;
    }
}
